<?php
/** @var TareaController $this */
/** @var Tarea $model */
$this->pageTitle = Tarea::label(2);
Util::tsRegisterAssetJs('admin.js');
$this->menu = array(
    array('label' => Yii::t('AweCrud.app', 'Create'), 'icon' => 'plus', 'visible' => Util::checkAccess(array("action_tarea_create")), 'url' => array('create')),
    array(
        'label' => 'Exportar', 'icon' => 'download-alt', 'url' => '#', 'visible' => Util::checkAccess(array("action_tarea_ExportExcel")), 'items' => array(
            array('label' => 'Todos', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporCont(true)')),
            array('label' => 'Seleccionados', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporCont(false)'))
        ),
    ),
    array('label' => Yii::t('AweCrud.app', 'Kanban'), 'icon' => 'trello', 'visible' => Util::checkAccess(array("action_tarea_kanban")), 'url' => array('kanban'),)
);
?>

<div class="widget red">


    <div class="widget-title">
        <h4><i class="icon-tasks"></i> <?php echo Yii::t('AweCrud.app', 'Manage') ?> <?php echo Tarea::label(2) ?></h4>
        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
        </span>
    </div>

    <div class="widget-body">
        <div class="row-fluid">
            <div class="span6">
                <?php
                $this->widget('ext.Truulo.TruuloModuleSearch', array(
                    'model' => $model,
                    'grid_id' => 'Tareas-grid',
                ));
                ?>
            </div>
            <div class="span6 etapa-filter">
                <input type="checkbox" id="Etapa_100"/> <?php echo Yii::t('AweCrud.app', 'Mostrar tareas de etapa ' . $Etapa_100); ?>
            </div>
        </div>
        <div style='overflow:auto'> 
            <?php
            $this->widget('ext.selgridview.BootSelGridView', array(
                'id' => 'Tareas-grid',
                'type' => 'striped bordered hover advance',
                "template" => "{items}{summary}{pager}",
                'dataProvider' => $elemento == 'validar' ? $model->activos()->noConcluidas()->ordenFechaFin()->search() : $model->activos()->ordenFechaFin()->search(),
                'selectableRows' => 2,
                'columns' => array(
                    array(
                        'class' => 'CCheckBoxColumn',
                    ),
                    array(
                        'name' => 'nombre',
                        'value' => 'CHtml::link($data->nombre, Yii::app()->createUrl("tareas/tarea/view/",array("id"=>$data->id)))',
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'entidad_id',
                        'value' => '!$data->entidad_id==null?CHtml::link($data->getNombreEntidad(), Yii::app()->createUrl($data->getAccionUrl(),array("id"=>$data->entidad_id))):""',
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'etapa_id',
                        'value' => '$data->etapa_id?$data->getEtapaName():""',
                        'type' => 'raw',
                    ),
                    array(
                        'name' => 'owner_id',
                        'value' => 'Yii::app()->user->um->loadUserById($data->owner_id)->username',
                    ),
                    array(
                        'name' => 'fecha_fin',
                        'type' => 'raw',
                        'value' => '"<span class=\"label label-mini ".Util::nicetimeColor($data->fecha_fin)." \">".Util::nicetime($data->fecha_fin)."</span>"'
                    ),
                    array(
                        'class' => 'CButtonColumn',
                        'template' => '{update} {delete}',
                        'buttons' => array(
                            'update' => array(
                                'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                                'options' => array('title' => 'Actualizar'),
                                'imageUrl' => false,
                                'visible' => 'Util::checkAccess(array("action_tarea_update"))',
                            ),
                            'delete' => array(
                                'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                                'options' => array('title' => 'Eliminar',),
                                'imageUrl' => false,
                                'visible' => 'Util::checkAccess(array("action_tarea_delete"))',
                            ),
                        ),
                        'htmlOptions' => array(
                            'width' => '80px'
                        )
                    ),
                ),
            ));
            ?>
        </div>
    </div>
</div>

<form id="formId" method="post" target="blank">
    <input type="hidden" id="id_tareas" name="Tareas">
</form>